package edu.ynu.MyProject.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import edu.ynu.MyProject.common.entity.Info;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
public class Equipment extends Info {
    @Column
    private String address;

    @Column
    private String unit;

    @Column
    private String monitorAddress;

    @Column
    private String type;

    @Column
    private String serial;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("equipments")
    private GreenHouseInfo greenhouse;

    @OneToMany(mappedBy = "equipment",
            fetch = FetchType.LAZY,
            orphanRemoval = true,
            cascade = CascadeType.ALL
    )
    @JsonIgnoreProperties("equipment")
    private Set<Data> datas;
}
